#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#include "uthash.h"

#include <iso646.h>

int compare_ints(const void* a, const void* b);
int check(int mid, int* arr);

int n, m;
int main()
{
	scanf("%d%*c%d", &n, &m);
	int* arr = (int*)malloc(n * sizeof(int));
	for (int i = 0; i < n; i++) scanf("%d", arr + i);
	qsort(arr, n, sizeof(int), compare_ints);
	int lo = 0, hi = arr[n - 1] - arr[0];
	while (lo < hi) {
		int mid = lo + (hi - lo >> 1);
		if (check(mid, arr)) lo = mid + 1;
		else hi = mid;
	}
	printf("%d\n", hi - 1);
	free(arr); return 0;
}

int check(int span, int* arr)
{
	int cnt = 1;
	for (int i = 1, prePos = arr[0]; i < n; i++)
		if (arr[i] - prePos >= span) {
			cnt++;
			prePos = arr[i];
		}

	return cnt >= m;
}

int compare_ints(const void* a, const void* b)
{
	int arg1 = *(const int*)a, arg2 = *(const int*)b;
	return (arg1 > arg2) - (arg1 < arg2); // 可行的简写
}
